package io;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class Test3 {
    public static void main(String[] args) throws FileNotFoundException {
        /*
        PrintWriter pw = new PrintWriter("jsb.txt");
        Scanner scan = new Scanner(System.in);
        while (true){
            String str = scan.next();
            if("exit".equalsIgnoreCase(str)){
                break;
            }
            pw.println(str);
            pw.flush();
        }
        System.out.println("写出完毕");
        pw.close();

         */
        FileOutputStream fos = new FileOutputStream("jsb_1.txt");
        OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
        BufferedWriter bw = new BufferedWriter(osw);
        PrintWriter pw = new PrintWriter(bw,true);
        Scanner scan = new Scanner(System.in);
        while (true){
            String str = scan.next();
            if("exit".equalsIgnoreCase(str)){
                break;
            }
            pw.println(str);
        }
        System.out.println("写出完毕");
        pw.close();
    }
}
